package inits

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"log"
	"shop/shop-server/basic/config"
)

func init() {
	InitMysql()
	//InitRedis()
	//InitConfig()
}

//func InitConfig() {
//
//}
//
//func InitRedis() {
//
//}

func InitMysql() {
	var err error
	// 参考 https://github.com/go-sql-driver/mysql#dsn-data-source-name 获取详情
	dsn := "root:root@tcp(127.0.0.1:3306)/shop?charset=utf8mb4&parseTime=True&loc=Local"
	config.DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		return
	}
	log.Println("mysql is success")
}
